package com.ledijiaoyu.autogate.packet.response;

import cn.dinkevin.xui.util.StringUtil;

/**
 * Create with Android Studio
 * Author: chengpengfei
 * Date: 2018/6/2
 * Time: 2:20 PM
 * Description:读取内存信息回复
 */
public class ReadMachineMemoryInfoResponse extends AutoGateResponse{

    private int mCardInformationCount;

    @Override
    public boolean decode(byte[] buffer) {
        boolean parentDecode = super.decode(buffer);
        boolean childDecode = false;
        if(parentDecode){
            // 数据包 H001G4233 SU AAAA ABU BBBB SB CCCC RD DDDDD
            // 只有 RD 之后的数据才是有效的
            mPoint = 9 + 6 + 7 + 6 + 2;
            char[] t_buffer = new char[]{mBuffer.get(mPoint++),
                            mBuffer.get(mPoint++),
                            mBuffer.get(mPoint++),
                            mBuffer.get(mPoint++),
                            mBuffer.get(mPoint++)};
            String t_count = StringUtil.char2String(t_buffer);
            mCardInformationCount = Integer.parseInt(t_count);
        }
        return parentDecode && childDecode;
    }

    public int getCardInformationCount(){
        return mCardInformationCount;
    }
}
